<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\Common;

class ConsumerApi
{
    public $conn;
    public $q_name;
    public $k_route;
    public function __construct()
    {
        $conn_args = ["host" => \think\facade\Config::get("rabbit.rabbit_host"), "port" => \think\facade\Config::get("rabbit.rabbit_port"), "login" => \think\facade\Config::get("rabbit.rabbit_login"), "password" => \think\facade\Config::get("rabbit.rabbit_passwd"), "vhost" => \think\facade\Config::get("rabbit.rabbit_vhost")];
        $this->e_name = \think\facade\Config::get("rabbit.rabbit_exchange_name");
        $this->q_name = \think\facade\Config::get("rabbit.rabbit_query_name");
        $this->k_route = \think\facade\Config::get("rabbit.rabbit_key");
        $this->conn = new AMQPConnection($conn_args);
        if(!$this->conn->connect()) {
            exit("Cannot connect to the broker!\n");
        }
    }
    public function consumerMessage()
    {
        $channel = new AMQPChannel($this->conn);
        $q = new AMQPQueue($channel);
        $q->setName($this->q_name);
        $q->setFlags(AMQP_DURABLE);
        while ($a = $q->declare()) {
            $gets = $q->get(AMQP_AUTOACK);
            $messages[] = $gets->getBody();
        }
        $this->conn->disconnect();
        return $messages;
    }
}

?>